home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / ASM-SPAR.{_A / IDE.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  6KB  |  269 lines

  1. /* $Id: ide.h,v 1.11 1998/08/12 22:19:37 ecd Exp $
  2.  * ide.h: Ultra/PCI specific IDE glue.
  3.  *
  4.  * Copyright (C) 1997  David S. Miller (davem@caip.rutgers.edu)
  5.  * Copyright (C) 1998  Eddie C. Dost   (ecd@skynet.be)
  6.  */
  7.  
  8. #ifndef _SPARC64_IDE_H
  9. #define _SPARC64_IDE_H
  10.  
  11. #ifdef __KERNEL__
  12.  
  13. #include <asm/pgtable.h>
  14.  
  15. typedef unsigned long ide_ioreg_t;
  16.  
  17. #undef  MAX_HWIFS
  18. #define MAX_HWIFS    2
  19.  
  20. #define    ide__sti()    __sti()
  21.  
  22. static __inline__ int ide_default_irq(ide_ioreg_t base)
  23. {
  24.     return 0;
  25. }
  26.  
  27. static __inline__ ide_ioreg_t ide_default_io_base(int index)
  28. {
  29.     return 0;
  30. }
  31.  
  32. static __inline__ void ide_init_hwif_ports(ide_ioreg_t *p, ide_ioreg_t base, int *irq)
  33. {
  34.     int i;
  35.  
  36.     /* These are simply offsets from base. */
  37.     for (i = 0; i < 8; i++)
  38.         *p++ = base++;
  39.     /* PCI code needs to figure out these. */
  40.     for ( ; i < 10; i++)
  41.         *p++ = 0;
  42.     /* PCI code needs to figure out this. */
  43.     if (irq != NULL)
  44.         *irq = 0;
  45. }
  46.  
  47. typedef union {
  48.     unsigned int        all    : 8;    /* all of the bits together */
  49.     struct {
  50.         unsigned int    bit7    : 1;
  51.         unsigned int    lba    : 1;
  52.         unsigned int    bit5    : 1;
  53.         unsigned int    unit    : 1;
  54.         unsigned int    head    : 4;
  55.     } b;
  56. } select_t;
  57.  
  58. static __inline__ int ide_request_irq(unsigned int irq,
  59.                       void (*handler)(int, void *, struct pt_regs *),
  60.                       unsigned long flags, const char *name, void *devid)
  61. {
  62.     return request_irq(irq, handler, SA_SHIRQ, name, devid);
  63. }
  64.  
  65. static __inline__ void ide_free_irq(unsigned int irq, void *dev_id)
  66. {
  67.     free_irq(irq, dev_id);
  68. }
  69.  
  70. static __inline__ int ide_check_region(ide_ioreg_t base, unsigned int size)
  71. {
  72.     return check_region(base, size);
  73. }
  74.  
  75. static __inline__ void ide_request_region(ide_ioreg_t base, unsigned int size,
  76.                       const char *name)
  77. {
  78.     request_region(base, size, name);
  79. }
  80.  
  81. static __inline__ void ide_release_region(ide_ioreg_t base, unsigned int size)
  82. {
  83.     release_region(base, size);
  84. }
  85.  
  86. #undef  SUPPORT_SLOW_DATA_PORTS
  87. #define SUPPORT_SLOW_DATA_PORTS 0
  88.  
  89. #undef  SUPPORT_VLB_SYNC
  90. #define SUPPORT_VLB_SYNC 0
  91.  
  92. #undef  HD_DATA
  93. #define HD_DATA ((ide_ioreg_t)0)
  94.  
  95. static __inline__ int ide_ack_intr(ide_ioreg_t status_port, ide_ioreg_t irq_port)
  96. {
  97.     return 1;
  98. }
  99.  
  100. /* From m68k code... */
  101.  
  102. #ifdef insl
  103. #undef insl
  104. #endif
  105. #ifdef outsl
  106. #undef outsl
  107. #endif
  108. #ifdef insw
  109. #undef insw
  110. #endif
  111. #ifdef outsw
  112. #undef outsw
  113. #endif
  114.  
  115. #define insl(data_reg, buffer, wcount) insw(data_reg, buffer, (wcount)<<1)
  116. #define outsl(data_reg, buffer, wcount) outsw(data_reg, buffer, (wcount)<<1)
  117.  
  118. #define insw(port, buf, nr) ide_insw((port), (buf), (nr))
  119. #define outsw(port, buf, nr) ide_outsw((port), (buf), (nr))
  120.  
  121. static __inline__ void ide_insw(unsigned long port,
  122.                 void *dst,
  123.                 unsigned long count)
  124. {
  125.     volatile unsigned short *data_port;
  126.     unsigned long end = (unsigned long)dst + count;
  127.     u16 *ps = dst;
  128.     u32 *pi;
  129.  
  130.     data_port = (volatile unsigned short *)port;
  131.  
  132.     if(((u64)ps) & 0x2) {
  133.         *ps++ = *data_port;
  134.         count--;
  135.     }
  136.     pi = (u32 *)ps;
  137.     while(count >= 2) {
  138.         u32 w;
  139.  
  140.         w  = (*data_port) << 16;
  141.         w |= (*data_port);
  142.         *pi++ = w;
  143.         count -= 2;
  144.     }
  145.     ps = (u16 *)pi;
  146.     if(count)
  147.         *ps++ = *data_port;
  148.  
  149.     __flush_dcache_range((unsigned long)dst, end);
  150. }
  151.  
  152. static __inline__ void ide_outsw(unsigned long port,
  153.                  const void *src,
  154.                  unsigned long count)
  155. {
  156.     volatile unsigned short *data_port;
  157.     unsigned long end = (unsigned long)src + count;
  158.     const u16 *ps = src;
  159.     const u32 *pi;
  160.  
  161.     data_port = (volatile unsigned short *)port;
  162.  
  163.     if(((u64)src) & 0x2) {
  164.         *data_port = *ps++;
  165.         count--;
  166.     }
  167.     pi = (const u32 *)ps;
  168.     while(count >= 2) {
  169.         u32 w;
  170.  
  171.         w = *pi++;
  172.         *data_port = (w >> 16);
  173.         *data_port = w;
  174.         count -= 2;
  175.     }
  176.     ps = (const u16 *)pi;
  177.     if(count)
  178.         *data_port = *ps;
  179.  
  180.     __flush_dcache_range((unsigned long)src, end);
  181. }
  182.  
  183. #define T_CHAR          (0x0000)        /* char:  don't touch  */
  184. #define T_SHORT         (0x4000)        /* short: 12 -> 21     */
  185. #define T_INT           (0x8000)        /* int:   1234 -> 4321 */
  186. #define T_TEXT          (0xc000)        /* text:  12 -> 21     */
  187.  
  188. #define T_MASK_TYPE     (0xc000)
  189. #define T_MASK_COUNT    (0x3fff)
  190.  
  191. #define D_CHAR(cnt)     (T_CHAR  | (cnt))
  192. #define D_SHORT(cnt)    (T_SHORT | (cnt))
  193. #define D_INT(cnt)      (T_INT   | (cnt))
  194. #define D_TEXT(cnt)     (T_TEXT  | (cnt))
  195.  
  196. static u_short driveid_types[] = {
  197.     D_SHORT(10),    /* config - vendor2 */
  198.     D_TEXT(20),    /* serial_no */
  199.     D_SHORT(3),    /* buf_type - ecc_bytes */
  200.     D_TEXT(48),    /* fw_rev - model */
  201.     D_CHAR(2),    /* max_multsect - vendor3 */
  202.     D_SHORT(1),    /* dword_io */
  203.     D_CHAR(2),    /* vendor4 - capability */
  204.     D_SHORT(1),    /* reserved50 */
  205.     D_CHAR(4),    /* vendor5 - tDMA */
  206.     D_SHORT(4),    /* field_valid - cur_sectors */
  207.     D_INT(1),    /* cur_capacity */
  208.     D_CHAR(2),    /* multsect - multsect_valid */
  209.     D_INT(1),    /* lba_capacity */
  210.     D_SHORT(194)    /* dma_1word - reservedyy */
  211. };
  212.  
  213. #define num_driveid_types       (sizeof(driveid_types)/sizeof(*driveid_types))
  214.  
  215. static __inline__ void ide_fix_driveid(struct hd_driveid *id)
  216. {
  217.     u_char *p = (u_char *)id;
  218.     int i, j, cnt;
  219.     u_char t;
  220.  
  221.     for (i = 0; i < num_driveid_types; i++) {
  222.         cnt = driveid_types[i] & T_MASK_COUNT;
  223.         switch (driveid_types[i] & T_MASK_TYPE) {
  224.         case T_CHAR:
  225.             p += cnt;
  226.             break;
  227.         case T_SHORT:
  228.             for (j = 0; j < cnt; j++) {
  229.                 t = p[0];
  230.                 p[0] = p[1];
  231.                 p[1] = t;
  232.                 p += 2;
  233.             }
  234.             break;
  235.         case T_INT:
  236.             for (j = 0; j < cnt; j++) {
  237.                 t = p[0];
  238.                 p[0] = p[3];
  239.                 p[3] = t;
  240.                 t = p[1];
  241.                 p[1] = p[2];
  242.                 p[2] = t;
  243.                 p += 4;
  244.             }
  245.             break;
  246.         case T_TEXT:
  247.             for (j = 0; j < cnt; j += 2) {
  248.                 t = p[0];
  249.                 p[0] = p[1];
  250.                 p[1] = t;
  251.                 p += 2;
  252.             }
  253.             break;
  254.         };
  255.     }
  256. }
  257.  
  258. static __inline__ void ide_release_lock (int *ide_lock)
  259. {
  260. }
  261.  
  262. static __inline__ void ide_get_lock (int *ide_lock, void (*handler)(int, void *, struct pt_regs *), void *data)
  263. {
  264. }
  265.  
  266. #endif /* __KERNEL__ */
  267.  
  268. #endif /* _SPARC64_IDE_H */
  269.